# @Version  : 1.0
# @Author   : wgq
# @File     : homework02.py
# @Date     : 2025/6/11 21:29
class Animal:
    def __init__(self,name,breed,aggressivity,life_value):
        self.name = name
        self.breed = breed
        self.aggressivity = aggressivity
        self.life_value = life_value

    def attack(self,Animal):
        Animal.life_value -= self.aggressivity
        if Animal.life_value <= 0:
            return True
        return False
    def eat(self):
        pass
    def showInfo(self):
        print("="*50)
        print(f"名字\t\t血量\t\t攻击力\t\t生命值")
        print(f"{self.name}\t\t{self.breed}\t\t{self.aggressivity}\t\t{self.life_value}")

class Cat(Animal):

    def eat(self):
        self.life_value += 50


class Dog(Animal):
    def eat(self):
        self.life_value += 30


cat = Cat("小花","狸花猫",40,140)
dog = Dog("大黄","拉布拉多",50,200)
cat.showInfo()
dog.showInfo()
while True:
    choice = input("请输入指令")
    if choice == "k" or choice == "K":
        if cat.attack(dog):
            dog.showInfo()
            break
        else:
            print(f"{dog.name}的生命值：{dog.life_value}")
    if choice == "-":
        if dog.attack(cat):
            cat.showInfo()
            break
        else:
            print(f"{cat.name}的生命值：{cat.life_value}")
    if choice == "L" or choice == "l":
        cat.eat()
        print(f"{cat.name}的生命值：{cat.life_value}")
    if choice == "+":
        dog.eat()
        print(f"{dog.name}的生命值：{dog.life_value}")
